/*
 * Copyright (C) 2012-2013 Alingsås Kommun
 *
 * This file is part of Alfresco customizations made for Alingsås Kommun
 *
 * The Alfresco customizations made for Alingsås Kommun is free software: 
 * you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * The Alfresco customizations made for Alingsås Kommun is distributed in the 
 * hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with the Alfresco customizations made for Alingsås Kommun. 
 * If not, see <http://www.gnu.org/licenses/>.
 */

package se.alingsas.alfresco.repo.scripts.ddmigration;

import java.util.Comparator;

import org.alfresco.util.VersionNumber;

public class VersionComparator implements Comparator<AlingsasDocument> {

	@Override
	public int compare(final AlingsasDocument document1,
			final AlingsasDocument document2) {
		final String v1 = document1.version;
		final String v2 = document2.version;

		// sort the list descending (ie. most recent first)
		return new VersionNumber(v1).compareTo(new VersionNumber(v2));
	}
	
}
